<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta id="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
		<meta name="apple-themes-web-app-capable" content="yes">
		<meta content="yes" name="apple-mobile-web-app-capable">
		<meta content="black" name="apple-mobile-web-app-status-bar-style">
		<meta content="telephone=no" name="format-detection">
		<meta content="email=no" name="format-detection">
		<meta name="format-detection" content="telephone=no">
		<title>忘记密码</title>
		<link rel="stylesheet" href="${s.base}/mobile/css/main.css" type="text/css" media="all">

		<link rel="stylesheet" href="${s.base}/mobile/css/weui.min.css">
		<link rel="stylesheet" href="${s.base}/mobile/css/jquery-weui.min.css">
	</head>

	<body> 
		<header id="header">
			<div class="header_con">
            	<a href="javascript:history.go(-1);"><span></span></a> 
                <div class="top_tit">忘记密码</div>
			</div>
		</header>
		<input type="hidden" value="${memberId}" id="memberId" />
		<div id="content_div">
             <div class="pay_02">
              <p class="border_bottom">登录名：<input type="text" id="phone" style="width: 80%;height: 0.8rem;line-height: 0.8rem;border: 0px; text-align: left;" placeholder="请输入注册手机号" /></p>
               <p class="border_bottom">验证码：
				   <input type="text" id="verifyCode" style="width: 50%;height: 0.8rem;line-height: 0.8rem;border: 0px; text-align: left;" placeholder="请输入验证码" />
				   <input type="button" id="verify" style="width: 27%;height: 0.6rem;line-height: 0.6rem;border: 0px; border-radius:5px; border:1px solid #F00; background:#FFF;" value="获取验证码"/>
			   </p>
				 <input type="hidden" id="oldVerifyCode" />

				 <p class="border_bottom" >新密码：
				 <input type="password" id="password" style="width: 80%;height: 0.8rem;line-height: 0.8rem;border: 0px; text-align: left;" placeholder="请输入新密码" />
				 </p>
             </div>
              <div class="pay_04 margin_top_1"><a href="javascript:void(0)" id="forgetPws" class="ui-btn">立即修改</a></div>
      </div>
        <!--底部-->
		<!--底部结束-->
		<script src="${s.base}/mobile/js/jquery-1.7.2.min.js"></script>
		<script src="${s.base}/mobile/js/jquery-weui.min.js"></script>
		<script type="text/javascript" src="${s.base}/mobile/js/common.js"></script>
		<script type="text/javascript" src="${s.base}/js/layer/layer.js"></script>
		<script type="text/javascript" src="${s.base}/js/base/commont.js"></script>

		<script type="text/javascript">
            $("#forgetPws").on("click",function () {
                var phone = $("#phone").val();
                var verifyCode = $("#verifyCode").val();
                var oldVerifyCode = $("#oldVerifyCode").val();
                var password = $("#password").val();
                if (phone == null || phone == ""){
                    $.toast("请输入手机号", "提示");
                    return false;
                }
                if (verifyCode == null || verifyCode == ""){
                    $.toast("请输入验证码", "提示");
                    return false;
                }
                /*if (oldVerifyCode == null || oldVerifyCode == ""){
                    $.toast("您未获取到验证码，请会重新发送", "提示");
                    return false;
                }
                if (oldVerifyCode != verifyCode){
                    $.toast("您输入的验证码有错，请重新输入！", "提示");
                    return false;
                }*/
                if (password == null || password == ""){
                    $.toast("请输入登录密码", "提示");
                    return false;
                }
                $.showLoading("正在提交中");
                $.ajax({
                    type: "POST",
                    url: "/phone/updateForgetPws",
                    data: {"phone":phone,"password":password},
                    success: function(result){
                        $.hideLoading();
                        if(1==result.returnInfo.state){
                            $.modal({
                                title: "提示",
                                text: "密码修改成功，前往登录页面！",
                                buttons: [
                                    { text: "确定", onClick: function(){
                                        window.location.href="/phone/loginPage?memberId="+$("#memberId").val();
                                } }
                                ]
                            });

                        }else{
                            $.toast(result.returnInfo.errorMsg, "提示");
                            showLayerAlertNoRefre(result.returnInfo.errorMsg);
                        }
                    },
                    error: function(result){
                        $.toast(result, "提示");
                    }
                });
            });

            $("#verify").on("click",function () {
                var phone = $("#phone").val();
                if (phone == null || phone == ""){
                    $.toast("请输入手机号", "提示");
                    return false;
                }
                timer(60);
                $.post("/phone/verifyCodeNoMember",{
                    phone : phone
                },function(result){
                    if(1==result.returnInfo.state){
                        $("#oldVerifyCode").val(result.returnInfo.errorMsg);
                        $.toast("发送成功！", "提示");
                    }else{
                        $.toast(result.returnInfo.errorMsg+"，请重试！", "提示");
                    }
                },"json");
            });

            function timer(time) {
                var btn = $("#verify");
                btn.attr("disabled", true);  //按钮禁止点击
                btn.val(time <= 0 ? "获取验证码" : ("" + (time) + "秒后可发送"));
                var hander = setInterval(function() {
                    if (time <= 0) {
                        clearInterval(hander); //清除倒计时
                        btn.val("获取验证码");
                        btn.attr("disabled", false);
                        return false;
                    }else {
                        btn.val("" + (time--) + "秒后可发送");
                    }
                }, 1000);
            }
		</script>
	</body>
</html>